export const d2a = (n: number) => {
  return n * Math.PI / 180;
}
export const drawCircle = (ctx: any, start: number, end: number, color: string, cx: number, cy: number, r: number) => {
  let x = cx + Math.cos(d2a(start)) * r;
  let y = cy + Math.sin(d2a(start)) * r;
  ctx.beginPath();
  ctx.moveTo(cx, cy);
  ctx.lineTo(x, y);
  ctx.arc(cx, cy, r, d2a(start), d2a(end), false);
  ctx.fillStyle = color;
  ctx.fill();
  ctx.stroke();
  ctx.closePath();
}
export const drawCircleText = (ctx: any, val: string, position: number, cx: number, cy: number, r: number) => {
  // console.log(position, cx,cy,r)
  ctx.beginPath();
  let x = cx + Math.cos(d2a(position)) * r / 1.25 - 20;
  let y = cy + Math.sin(d2a(position)) * r / 1.25;
  ctx.fillStyle = '#000';
  ctx.font = '20px 微软雅黑';
  ctx.fillText(val, x, y);
  ctx.closePath();
}